# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dernierepage.ui'
#
# Created: Wed Apr  8 10:26:46 2009
#      by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!

import re
import os
import sys
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import Qt
from Main import *
from DAC.DBA.dbmanager import DBInterface

class Page10(object):
    def __init__(self,session):
		self.session=session
		self.app = QtGui.QApplication(sys.argv)
		self.window=QtGui.QDialog()
                self.retour=0
                self.parametre={}
                self.config={}
		self.oldx = 0
		self.oldy = 0
                self.nbMesure=0


    def fin(self):
        self.window.close()
        db=DBInterface("./DAC/DBA/dbaccess.config")
        db.exportDataToFile("/tmp/export.xml")

    def setupUi(self, Dialog):
        dicosalle={}
	expr=re.compile('[a-zA-Z]')        
        fichier=open('dicosalle','r')
        for line in fichier.readlines():
            if expr.findall(line):
                dicosalle[line.split(':')[0].split('\n')[0]]=line.split(':')[1].split('\n')[0]
        fichier.close()
        Dialog.setObjectName("Dialog")
        Dialog.resize(1280, 740)
        self.lineEdit_plan_salle = QtGui.QLineEdit(Dialog)
        self.lineEdit_plan_salle.setGeometry(QtCore.QRect(360, 10, 551, 71))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(32)
        font.setWeight(50)
        font.setBold(False)
        self.lineEdit_plan_salle.setFont(font)
        self.lineEdit_plan_salle.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_plan_salle.setReadOnly(True)
        self.lineEdit_plan_salle.setObjectName("lineEdit_plan_salle")
        

        #Widget pour la partie droite
        self.groupe_image = QtGui.QWidget(Dialog)
        self.groupe_image.setGeometry(QtCore.QRect(40,90,1200,800))
        self.groupe_image.setObjectName("groupe_image")

        #cadre autour du plan
        self.frame = QtGui.QFrame(self.groupe_image)
        self.frame.setGeometry(QtCore.QRect(10, 10, 1150, 530))
        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtGui.QFrame.Raised)
        self.frame.setObjectName("frame")       

        # plan de la salle
        dicosalle={} 
        expr2=re.compile('[a-zA-Z]')        
        fic=open('dicosalle','r')
        for line in fic.readlines():
            if expr2.findall(line):
                dicosalle[line.split(':')[0].split('\n')[0]]=line.split(':')[1].split('\n')[0]
        fic.close()
        lien=dicosalle["url_plan"].split(".")[0]+"_final.png"
        objImg = QtGui.QImage(lien)

        # label qui contiendra le plan
        self.plan = QtGui.QLabel(self.frame)
	self.plan.setPixmap(QtGui.QPixmap.fromImage(objImg.scaled(1150,530,Qt.KeepAspectRatio,Qt.FastTransformation)))
        self.pushButton_fin = QtGui.QPushButton(Dialog)
        self.pushButton_fin.setGeometry(QtCore.QRect(1064, 650, 171, 45))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_fin.setFont(font)
        self.pushButton_fin.setObjectName("pushButton_fin")

        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.pushButton_fin, QtCore.SIGNAL("clicked()"), self.fin)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def affich(self,param):
	self.setupUi(self.window)
	self.window.show()
        sys.exit(self.app.exec_())


    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_plan_salle.setText(QtGui.QApplication.translate("Dialog", "RESULTAT OBTENU", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_fin.setText(QtGui.QApplication.translate("Dialog", "export XML", None, QtGui.QApplication.UnicodeUTF8))

